package com.kk.framework.ui.framewest;

import org.zkoss.zul.A;
import org.zkoss.zul.Div;
import org.zkoss.zul.Hbox;
import org.zkoss.zul.Hlayout;
import org.zkoss.zul.Image;
import org.zkoss.zul.Label;
import org.zkoss.zul.Vbox;

import com.kk.framework.session.SystemSessionManager;
import com.kk.framework.session.UserSessionObject;
import com.kk.framework.util.StringUtils;

@SuppressWarnings("serial")
public class UserLoginInfoPanel extends Div
{
	private UserSessionObject	_gblSessObj;
	private String				_userName		= "";
	private String				_deptName		= "";
	private String				_userImgPath	= "";

	public UserLoginInfoPanel()
	{
		this._gblSessObj = SystemSessionManager.getGblUserSessionData();

		this.loadData();
		this.initLayout();
	}

	private void loadData()
	{
		this._userName = "杨晓康";
		this._deptName = "神盾局";
	}
	
	private void initLayout()
	{
		this.setStyle("padding-left:10px;padding-top:15px;padding-bottom:15px;border-bottom:1px solid #acaeb0");
		
		Hlayout mainLayout = new Hlayout();
		this.appendChild(mainLayout);
		
		Div paddingDiv = new Div();
		String divStyle = 
				"border:2px solid #fff;" +
				"margin:5px;" +
				"box-shadow: 0 0 10px #a0a0a0;" +
				"-webkit-box-shadow: 0 0 10px #a0a0a0;" +
				"-moz-box-shadow: 0 0 10px #a0a0a0;";
		paddingDiv.setStyle(divStyle);
		mainLayout.appendChild(paddingDiv);

		Image userImg = new Image();
		userImg.setWidth("50px");
		userImg.setHeight("50px");
		if (StringUtils.isEmpty(this._userImgPath))
		{
			userImg.setSrc("./imgs/nopic.png");
		}
		else
		{
			userImg.setSrc(this._userImgPath);
		}
		paddingDiv.appendChild(userImg);
		
		paddingDiv = new Div();
		paddingDiv.setStyle("padding-top:7px;padding-left:5px");
		mainLayout.appendChild(paddingDiv);
		
		Vbox vbox = new Vbox();
		paddingDiv.appendChild(vbox);
		Label lblUserName = new Label(this._userName);
		vbox.appendChild(lblUserName);
		Label lblDeptName = new Label(this._deptName);
		vbox.appendChild(lblDeptName);
		Hbox hbox = new Hbox();
		hbox.setSpacing("8px");
		vbox.appendChild(hbox);
		A linkSetting = new A("个人设置");
		hbox.appendChild(linkSetting);
		A linkLogout = new A("退出系统");
		hbox.appendChild(linkLogout);
	}
}
